﻿using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;
using PsiIndexer;

namespace PsiIndexerGUI {
  public class DirectionBrushConverter : IValueConverter {
    private readonly Brush fromBrush;
    private readonly Brush toBrush;

    public DirectionBrushConverter() {
      this.fromBrush = new LinearGradientBrush(Colors.Transparent, Colors.LightBlue, 0);
      this.fromBrush.Freeze();
      this.toBrush = new LinearGradientBrush(Colors.LightSeaGreen, Colors.Transparent, 0);
      this.toBrush.Freeze();
    }

    #region IValueConverter Members

    public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
      var cd = (ChatDirection) value;
      switch (cd) {
        case ChatDirection.FROM:
          return this.fromBrush;
        case ChatDirection.TO:
          return this.toBrush;
        default:
          return new SolidColorBrush(Colors.Red);
      }
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
      throw new NotImplementedException();
    }

    #endregion
  }
}